<template>
    <div>
        <common-title :stitle="'公告'" />
        <div style="height: 300px; overflow: auto; clear: both;">
            <van-cell-group>
                <template v-for="item in alldata.data">
                    <van-cell :key="item.strID" :title="item.strName" :value="item.strPublish" is-link @click="clickBulletin(item.strID)"></van-cell>
                </template>
            </van-cell-group>
        </div>
        <van-popup v-model="show" round>
            <div style="width: 300px; height: 70vh; padding: 2vh; box-sizing: border-box;">
                <div style="text-align: center; font-size: 24px; font-weight: 700; clear: both; margin-bottom: 1vh;">{{ title }}</div>
                <div v-html="content" style="max-height: 56vh; overflow: auto; border: 1px solid #d9d9d9; padding: 10px; box-sizing: border-box;"></div>
            </div>
        </van-popup>
    </div>
</template>

<script>
import qs from 'qs'
import Vue from 'vue'
import { Cell, CellGroup, Toast, Popup } from 'vant'
import commonTitleMixin from '../mixins/commonTitleMixin'
Vue.use(Cell).use(CellGroup).use(Toast).use(Popup)
export default {
    name: 'bulletin',
    data: function () {
        return {
            show: false,
            title: '无标题',
            content: '无内容'
        }
    },
    props: ['alldata'],
    mixins: [commonTitleMixin],
    mounted () {
        // //console.log('公告', this.alldata)
    },
    methods: {
        clickBulletin (id) {
            let data = { bulletin_id: id }
            this.axios({
                method: 'post',
                url: '/api/bulletin.showcontent.do',
                data: qs.stringify(data)
            }).then(res => {
                //console.log('res', res)
                this.show = true
                this.title = res.data.sname
                this.content = res.data.val
            }).catch(res => {
                this.reserror(res)
            })
        }
    }
}
</script>
